local Laser = Material("cable/redlaser")
Beams = {}
BCount = 0


hook.Add("ShotFired","regshot",function(ply,spread)
	print(spread[1].." "..spread[2].." "..spread[3])
	
	local tr = {}
	tr.start=ply:GetShootPos()
	tr.endpos=ply:GetShootPos()+ply:GetAimVector()*999999+spread*999999
	tr.filter=ply
	
	local trdat=util.TraceLine(tr)
	local hit=trdat.HitPos
	
	table.insert(Beams, {[1] = ply:GetShootPos(), [2] = hit})
	BCount=BCount+1
	print("DM: "..BCount.." Shots fired!")
	timer.Create("undobeam"..BCount,2,1,function()
		table.remove(Beams,1)
	end)
end)


hook.Add("PostDrawOpaqueRenderables","dm_render", function()
	render.SetMaterial(Laser)
	for k,v in pairs(Beams) do
		render.DrawBeam(v[1], v[2], 5, 0, 0, Color(255, 255, 255, 255))
	end
end)